<!doctype html>
<head>
  <meta charset="utf-8">

  <title>My Parse App</title>
  <meta name="description" content="My Parse App">
  <meta name="viewport" content="width=device-width">
  <link rel="stylesheet" href="css/reset.css">
  <link rel="stylesheet" href="css/styles.css">
  <link rel="stylesheet" href="css/drawingboard.min.css">
  <script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/2.0.3/jquery-2.0.3.min.js"></script>
  <script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.3.2.min.js"></script>
  <script type="text/javascript" src="js/base64.js"></script>
  <script type="text/javascript" src="js/drawingboard.min.js"></script>
</head>

<body>
  
  <div id="main">
    <h1>You're ready to use Parse!</h1>

    <p>Read the documentation and start building your JavaScript app:</p>

    <ul>
      <li><a href="https://www.parse.com/docs/js_guide">Parse JavaScript Guide</a></li>
      <li><a href="https://www.parse.com/docs/js">Parse JavaScript API Documentation</a></li>
    </ul>

    <div style="display:none" class="error">
      Looks like there was a problem saving the test object. Make sure you've set your application ID and javascript key correctly in the call to <code>Parse.initialize</code> in this file.
    </div>

    <div style="display:none" class="success">
      <p>We've also just created your first object using the following code:</p>
      
        <code>
          var TestObject = Parse.Object.extend("TestObject");<br/>
          var testObject = new TestObject();<br/>
          testObject.save({foo: "bar"});
        </code>
    </div>

    <canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;">

    </canvas>

    <div id="default-board" style="width: 800px; height: 600px; text-align: center;"></div>
    
  </div>

  

  <script type="text/javascript">
    Parse.initialize("QhfgEEXvd0e36BM9fwxZTMuhTpQBtjf9jzadh2Tt", "ADg6JB5rhHmXpgkEIkkdy2DqTExKdnZAxTzHUHno");


     //file 
    var base64 = "V29ya2luZyBhdCBQYXJzZSBpcyBncmVhdCE=";
    base64 = Base64.encode("Hello World, Welcome to opendeliver. 中国香港，台湾。 阿拉伯语，简称阿语（العربية‎ al-ʻarabīyah [alʕaraˈbijja] 或者 عربي/عربى‎ ʻarabī [ˈʕarabiː]，英语：Arabic language），是指源自公元6世纪的古典阿拉伯语的一种或多种语言。");

    //var parseFile = new Parse.File("opendeliver.txt", { base64: base64 });

    var bytes = [ 0xBE, 0xEF, 0xCA, 0xFE ];
    var parseFile = new Parse.File("myfile.txt", bytes);

    // save Text
    // parseFile.save().then(function() {
    //   // The file has been saved to Parse.
    //   //alert("file save success.");
    //   console.log(parseFile.url());
    // }, function(error) {
    //   // The file either could not be read, or could not be saved to Parse.
    //   //alert("file save fail.");
    // });


    
    var TestObject = Parse.Object.extend("TestObject");
    var testObject = new TestObject();

      testObject.set("foo", "bar22");
      testObject.set("file", parseFile);
      // testObject.save().then(function(){
      //     $(".success").show();
      //   },
      //   function(error) {
      //     $(".error").show();
      //   }
      // );

      //file 
    // var base64 = "V29ya2luZyBhdCBQYXJzZSBpcyBncmVhdCE=";
    // var parseFile = new Parse.File("myfile.txt", { base64: base64 });

    // parseFile.save().then(function() {
    //   // The file has been saved to Parse.
    //   alert("file save success.");
    // }, function(error) {
    //   // The file either could not be read, or could not be saved to Parse.
    //   alert("file save fail.");
    // });
    
    function aa(){

    }
    function canvasDraw(){
      var c = document.getElementById("myCanvas");
      var ctx = c.getContext("2d");
      ctx.font = "30px Arial";
      ctx.fillText("Hello World",10,50);

      ctx.beginPath();
      ctx.arc(95,50,40,0,2*Math.PI);
      ctx.stroke();

      //var imgData = ctx.getImageData(0,0,c.width,c.height);

      var imgData = c.toDataURL("image/png");
      console.log(imgData);

      //var parseFile = new Parse.File("image1.png", imgData);
      var parseFile = new Parse.File("opendeliver.png", { base64: imgData });

      //save file
      // parseFile.save().then(function() {
      //   // The file has been saved to Parse.
      //   //alert("file save success.");
      //   console.log(parseFile.url());
      // }, function(error) {
      //   // The file either could not be read, or could not be saved to Parse.
      //   //alert("file save fail.");
      // });

      }

    canvasDraw();

    //create the drawingboard by passing it the #id of the wanted container
	var defaultBoard = new DrawingBoard.Board('default-board',{
		droppable: true,
		background:"img/QQ_Photo20141202192150.jpg"
	});

  </script>
</body>

</html>
